home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0195_Making your Delphi apps show minimized.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-11-29  |  1.2 KB  |  31 lines

  1.  
  2. Q: When I select the "Run Minimized" option in Program Manager
  3.    to attempt to make my Delphi application execute in a minimized
  4.    state, the Delphi application seems to ignore the setting and
  5.    run normally. Why is this, and how to I fix it?
  6.  
  7. A: Delphi's Application object creates a hidden "application
  8.    window," and it is that window, rather than your main form,
  9.    that is being sent the command to show minimized. To fix this,
  10.    make your main form's OnCreate event handler look like this:
  11.  
  12.       procedure TForm1.FormCreate(Sender: TObject);
  13.       {$IFDEF WIN32}           { Delphi 2.0 (32 bit) }
  14.       var
  15.         MyInfo: TStartUpInfo;
  16.       {$ENDIF}
  17.       begin
  18.       {$IFDEF WIN32}           { Delphi 2.0 (32 bit) }
  19.         GetStartUpInfo(MyInfo);
  20.         ShowWindow(Handle, MyInfo.wShowWindow);
  21.       {$ENDIF}
  22.       {$IFDEF WINDOWS}         { Delphi 1.0 (16 bit) }
  23.         ShowWindow(Handle, cmdShow);
  24.       {$ENDIF}
  25.       end;
  26.  
  27.    In other words, for 16 bits, just pass cmdShow to ShowWindow.
  28.    For 32 bits you need to obtain the start up info by calling the
  29.    GetStartUpInfo procedure, which fills in a TStartUpInfo record,
  30.    and then pass TStartUpInfo.wShowWindow to ShowWindow.
  31.